<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>对象Object</title>
</head>
<body>
    <script>
        //对象类型引用
        let obj1={
            name:'whh',
            age:12,
            5:true
        }
        //obj1.name     whh
        //obj1['name']  whh
        //obj1.age      12
        //obj1['age']   12
        //obj1[5]       true
        //obj1['5']     true   

        let obj2=new Object();
        obj2.name='whh';
        obj2.age=12;
        //obj2.name     whh
        //obj2['name']  whh
        //obj2.age      12
        //obj2['age']   12 

        let obj3={
            'name':'whh',
            'age':12,
            '5':true,
            'first name':'w',
            'last name':'hh'
        }
        //obj3.name     whh
        //obj3['name']  whh
        //obj3.age      12
        //obj3['age']   12
        //obj3[5]       true
        //obj3['5']     true
        //obj3['first name] w
        //obj3['last name'] hh

        let foo='bar';
        let obj4={foo};
        let obj5={foo:foo};
        //obj4      {foo:'bar'}
        //obj5      {foo:'bar'}
        
        // function f(x,y){
        //     var m='whh';
        //     var n=20;
        //     return {x:m,y:n};
        // }
        var f=(x,y)=>{return {a:x,b:y}};


        function f1(x,y){
            return {
                m:x,
                n:y
            };
        }
        var f1=(x,y)=>{return {m:x,n:y}};

        
        let obj6=f('whh',20);
        let obj7=f1('whh',12);
        //obj6  {a:whh,b:20};
        //obj7  {m:whh,n:12};

        var obj8={
            method:function(){
                console.log('hello');
            }
        }
        
        var obj8={
            method(){
                console.log('hello');
            }
        }


        //注意这种方法 this不能用于 方法内
        var obj8={
            method:()=>{
                console.log('hello');
            }
        }

        //综合 例子1：
        const birth='1988/07/17';
        const name='ghy';
        let person={
            name,//相当于 name:name,
            birth,
            say(){
                console.log(this.name+this.birth);
            }
        }
        //person    {name:'ghy',birth:'1988/07/17',say:function say(){..}};


        //例子2
        let pf=(arg1,arg2)=>{
            return{
                name:arg1,
                birth:arg2,
                say(){
                    console.log(this.name+this.birth);
                }
            }
        }
        let person1=pf('whh1','19880717');

         //person1    {name:'whh1',birth:'19880717',say:function say(){..}}

        let obj9={
            ['a'+'bc']:'whh',
            [1+2]:true,
            ['first'+' '+'name']:'w'
            };
        //          { 3: true, abc: "whh", "first name": "w" }


        let obj10p='hollo world';
        let obj10={
            'hell you':'helloyou',
            [obj10p]:obj10p
        }
        //          { "hell you": "helloyou", "hollo world": "hollo world" }


        let obj11={
            obj10p,
        }
        //          { obj10p: "hollo world" }

        let obj12={
            ['f'+'un'+12](){
                console.log('fun12');
            }
        }
    </script>
</body>
</html>